package com.example.ycymyapplication;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.widget.TextView;

public class ShouYeActivity extends AppCompatActivity {
    TextView tv_userinfo;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_shou_ye);

        tv_userinfo = findViewById(R.id.tv_userinfo);

        SharedPreferences userSetting = getSharedPreferences("my", MODE_PRIVATE);
        String id=userSetting.getString("id","");
        if (id==""){
            startActivityForResult(new Intent(this,DengLuActivity.class),1001);
        }
        else{
            tv_userinfo.setText("用户信息："+"\n"+"id:"+id);

        }
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode==1001&&resultCode==1002){
            if (data!=null){
                String id=data.getStringExtra("id");
                tv_userinfo.setText("用户信息："+"\n"+"id:"+id);
            }
        }
    }


}
